package com.amigo.online.provider.adv.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.amigo.online.common.base.controller.BaseController;
import com.amigo.online.common.core.response.Response;
import com.amigo.online.common.core.security.IgnoreSecurity;
import com.amigo.online.provider.adv.service.AdvService;

@RestController
@RequestMapping(value = "/area", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class AreaController extends BaseController {

    @Autowired
    AdvService advService;

    /**
     * 根据cityId获取城市名和对应的省的名字，column为制定的列(如name_pt或者name_cn),不传默认为name_cn
     *
     * @param cityId
     * @param column
     * @return
     */
    @IgnoreSecurity
    @GetMapping(value = "/getProvinceAndCityByCityId/{cityId}/{column}")
    public ResponseEntity<Response> getProvinceAndCityByCityId(@PathVariable Long cityId,
                                                               @PathVariable String column) {
        return success(advService.getProvinceAndCityByCityId(cityId, column == null ? "name_pt" : column));
    }
}
